<template>
	<view class="contina bBtn_p_b140">
		<view class="w seach">
			<searchCom></searchCom>
		</view>
		<view class="w" style="height: calc(100% - 132rpx);">
			<scroll-view scroll-y class="scrollView" v-if="list.length > 0" @scrolltolower="getList">
				<template v-for="(item,idx) in list">
					<view class="card">
						<view class="top flex_a_c">
							<image v-if="item.id_photo" :src="item.id_photo"></image>
							<image v-else src="../../static/image/robot.png"></image>
							<view class="ri_text">
								<view class="I item"><text style="color: #000000;">{{item.name}}</text><text
										style="color: #3586FC;margin-left: 30rpx;">{{item.phone}}</text></view>
								<view class="II item"><text style="color: #999999;">部门</text><text
										style="color: #000000;margin-left: 20rpx;">{{item.dept.name}}</text></view>
								<view class="III item"><text style="color: #999999;">职位</text><text
										style="color: #000000;margin-left: 20rpx;">{{item.job}}</text></view>
							</view>
						</view>
						<view class="bot">
							<view class="del" @click="del(item.id,idx)">删除</view>
							<view class="se" @click="$fun.toPage('/pagesA/talents/form?edit=1&id='+item.id)">查看</view>
						</view>
						<view class="tip">
							{{item.full_job?'全职':'兼职'}}
						</view>
					</view>
				</template>
			</scroll-view>
			<view class="no" v-else>
				<image src="../../static/image/none.png"></image>
				<view class="em">暂无数据</view>
			</view>
		</view>
		<flooterCom text="新增" @click="toAdd"></flooterCom>
	</view>
</template>

<script>
	import searchCom from "@/compoment/searchCom.vue";
	import flooterCom from "@/compoment/flooterCom.vue"
	export default {
		data() {
			return {
				list: [],
				page: 1,
				name: '',
			}
		},
		components: {
			searchCom,
			flooterCom
		},
		onShow() {
			this.getList()
			uni.$on('search_list', (v) => {
				this.name = v
				this.page = 1
				this.list = []
				this.getList()
			})
		},
		onHide() {
			this.page=1
			this.list=[]
		},
		methods: {
			toAdd() {
				uni.navigateTo({
					url: "/pagesA/talents/form"
				})
			},
			async getList() {
				let res = await this.$api.staffApi.list({
					page: this.page,
					name: this.name
				})
				if (res.list.length) {
					this.list = this.list.concat(res.list)
					this.page++
				}
			},
			del(id, idx) {
				uni.showModal({
					content: '确定删除吗？',
					success: (res) => {
						if (res.confirm) {
							this.$api.staffApi.del({
								ids: [id]
							}).then(() => {
								uni.showToast({
									icon: 'none',
									title: '删除成功'
								})
								this.list.splice(idx, 1)
							})

						}
					}
				});

			}
		}
	}
</script>

<style lang="scss">
	.contina {
		height: 100%;

		.seach {
			height: 112rpx;
			padding: 20rpx 30rpx;
			background-color: #fff;
			// margin-bottom: 20rpx;
			box-sizing: border-box;
		}

		.scrollView {
			height: 100%;

			.card {
				padding: 30rpx;
				box-sizing: border-box;
				position: relative;
				margin-top: 20rpx;

				.top {
					image {
						width: 160rpx;
						height: 160rpx;
						border-radius: 12rpx;
					}

					.ri_text {

						.II,
						.III {
							margin-top: 20rpx;
						}

						.item {
							font-size: 28rpx;
						}
					}
				}

				.bot {
					display: flex;
					align-items: center;
					justify-content: flex-end;
					margin-top: 30rpx;

					.del {
						width: 116rpx;
						height: 56rpx;
						background: #FFFFFF;
						border-radius: 50px 50px 50px 50px;
						opacity: 1;
						border: 1px solid #F07878;
						text-align: center;
						line-height: 56rpx;
						font-size: 28rpx;
						color: #FF0000;
					}

					.se {
						width: 116rpx;
						height: 56rpx;
						background: #FFFFFF;
						border-radius: 50px 50px 50px 50px;
						opacity: 1;
						border: 1px solid #78AEF0;
						line-height: 56rpx;
						text-align: center;
						font-size: 28rpx;
						color: #0074FF;
						margin-left: 20rpx;
					}
				}

				.tip {
					position: absolute;
					top: 0;
					right: 0;
					background-color: #DF9E5C;
					width: 108rpx;
					height: 48rpx;
					font-size: 24rpx;
					color: #fff;
					border-radius: 0px 10px 0px 10px;
					line-height: 48rpx;
					text-align: center;
				}
			}
		}

		image {
			width: 412rpx;
			height: 284rpx;
			border-radius: 0px 0px 0px 0px;
		}

		.no {
			margin-top: 50rpx;
			display: flex;
			justify-content: center;
			flex-direction: column;
			align-items: center;
			margin-top: 332rpx;

			.em {
				width: 128rpx;
				height: 50rpx;
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #888888;
			}
		}


	}
</style>